package com.shujia

import scala.io.Source

object WordCountScala {
  def main(args: Array[String]): Unit = {
    Source
      .fromFile("scala_code/data/words.txt")
      .getLines()
      .toList
      .flatMap {
        case line: String => line.split(" ")
      }
      .groupBy {
        case x: String => x
      }
      .map {
         case (word, list: List[String]) =>
           (word, list.size)
      }
      .foreach(println)

  }
}
